import unittest
from functools import wraps

def data(*args):
    def wrapper1(func):
        func.data=args
        return func
    return wrapper1

def update_test_func(func,value):
    @wraps(func)
    def wrapper2(self,*args,**kwargs):
        return func(self,value)
    return wrapper2

def ddt(cls):
    print(cls.__dict__)
    for name,func in list(cls.__dict__.items()):
        if hasattr(func,"data"):
            for index,value in enumerate(getattr(func,"data")):
                # 每遍历出来一条数据，就动态给用例添加一个方法
                new_func_name=name+str(index)
                new_func=update_test_func(func,value)
                setattr(cls,new_func_name,new_func) # 动态设置方法
            else:
                delattr(cls,name) # 删除函数属性
    return cls
print("hello")
@ddt
class TestLogin(unittest.TestCase):
    @data(11,22,33,44)
    def test_func(self,case):
        print(case)
    @data(55,66,77,88,99)
    def test_func2(self,case):
        print(case)